#include <QtWidgets>
#include <qwidget.h>

class macroSlider: public QWidget
{
    Q_OBJECT
public:
    explicit macroSlider(QWidget* parent);

    void setValue1(double value);
	void setValue2(double value);
	void setValues(double val1, double val2);
    void setRange(double min, double max);
	void increaseMaxValue(double max);
	void setStep(double step);
	void setSubSplit(int count);
	void setDigits(int count);
protected:
    virtual QSize minimumSizeHint() const;
    virtual void leaveEvent(QEvent* event);
    virtual void mouseMoveEvent(QMouseEvent* event);
    virtual void mousePressEvent(QMouseEvent* event);
    virtual void mouseReleaseEvent(QMouseEvent* event);
    virtual void keyPressEvent(QKeyEvent* event);
    virtual void paintEvent(QPaintEvent* event);

signals:
    void Value1Changed(double);
	void Value2Changed(double);
	void ZoneChanged(double, double);
private:
	double getPosFromValue(const double &value) const;
	double getValueFromPos(const double &pos) const;
	void checkMouseOver(const QPoint &current_pos);
	void round(double &value);
private:
	double WIDTH;
    double Min;
    double Max;
	double Step;
	int subSplit;
	int digits;
    double value1;
	double value2;
	double dist_to_value1;
	double dist_to_value2;
	double distance;
    bool IsMouseOverSlider1;
	bool IsMouseOverSlider2;
	bool IsMouseOverSelectedZone;
    bool IsMovingSlider1;
	bool IsMovingSlider2;
	bool IsMovingSelectedZone;
    QRectF Slider1Rect;
	QRectF Slider2Rect;
	QRectF SelectedZoneRect;
};